import { create, update, remove, query } from '../../../../../../framework/service/index';
import { ToastTips } from '../../../../../../common/toastTips/tosat';
import { routerRedux } from 'dva/router';

export default {

  namespace: 'withdrawCash',

  state: {
    data: [],
    list: {},
    applicationId:'',
    cash:0,
    messageTips:'',
    isShowTips:false,
  },

  subscriptions: {
    setup({ dispatch, history }) {
      history.listen(location => {
        if(location.pathname === '/withdraw-cash') {
          // const applicationId = location.query.id;
          // console.log('jobId', applicationId);
          // dispatch({
          //   type: 'querySuccess',
          //   payload: {
          //     applicationId
          //   }
          // })
        }
      })
    },
  },

  effects: {

    *postAmount({ payload }, { call, put, select }) {

      // console.log('payload', JSON.stringify(payload));
      const { code, data, message } = yield call(create, `/api/parttime/withdraw-application`, {...payload});

      // console.log('code', JSON.stringify(code));
      // console.log('data', JSON.stringify(data));
      // console.log('message', JSON.stringify(message));

      if (code === 200) {
        yield put({
          type:'querySuccess',
          payload:{
            messageTips:data,
            isShowTips:true,
          }
        })
      }else{
        console.log('发送失败');
      }
    },
  },

  reducers: {
    querySuccess(state, action) {
      return { ...state, ...action.payload };
    },
  }

};
